/*   
 * Copyright (c) 2010-2020 DMGIS Ltd. All Rights Reserved.   
 *   
 * This software is the confidential and proprietary information of   
 * DMGIS. You shall not disclose such Confidential Information   
 * and shall use it only in accordance with the terms of the agreements   
 * you entered into with DMGIS.   
 *   
 */
package com.dmgis.qxfw.dataservice.commonservice.dmgis_mongodb_srv.common.domain;

import java.io.InputStream;
import java.util.Properties;

/**
 * This class is used for 系统配置文件
 * 
 * @author dsq
 * @version 1.0, 2018年8月18日 下午1:51:28
 */
public class DbConfig {
	public  static String MONGDBNAME;
	public  static String HOST;
	public  static int PORT;
	static {
        Properties prop = new Properties();
        // 通过Object.class获取资源路径 path
        // 不以’/'开头时默认是从此类所在的包下取资源，以’/'开头则是从ClassPath根下获取。其只是通过path构造一个绝对路径，最终还是由ClassLoader获取资源。
        InputStream in = DbConfig.class.getClassLoader().getResourceAsStream("dbconfig.properties");
        try {
            prop.load(in);
            // 获取value
            MONGDBNAME = prop.getProperty("dbname");
            HOST=prop.getProperty("host");
            PORT=Integer.parseInt(prop.getProperty("port"));
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
}